package com.szty.libarytest.room

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import com.szty.libarytest.room.User

@Dao
interface UserDao {
    @Query("SELECT* FROM user")
    fun getAll(): List<User>

    @Query("SELECT* FROM user WHERE uid IN (:userIds)")
    fun loadAllByIds(userIds: IntArray): List<User>

    /**
     * 查询最后一个数据，如果表是空的，会返回null
     */
    @Query("SELECT * FROM user LIMIT 1")
    fun getFirstData(): User

    @Insert
    fun insertAll(vararg users: User)

    @Delete
    fun delete(user: User)
}
